# -*- coding: utf-8 -*-
import numpy as np
import  matplotlib.pyplot as plt
from cvxopt import matrix, solvers
# x<=2
# y<=2
# x+y>=2
# 求z=x+2y的取值范围
A = matrix([[1.0, 0.0, -1.0], [0.0, 1.0, -1.0]])
b = matrix([2.0, 2.0, -2.0])
c = matrix([1.0, 2.0])
d = matrix([-1.0, -2.0])

sol1 = solvers.lp(c,A,b)
min = np.dot(sol1['x'].T, c)
sss= sol1['x']
print(sss)
sol2 = solvers.lp(d,A,b)
max = -np.dot(sol2['x'].T, d)

print('min=%s,max=%s'%(min[0][0], max[0][0]))


# fig= plt.figure
# fig.subplot(111)
# plt.plot(x)

